﻿@{
    Bundle("jquery_validate");
}


<table>
    <tr>
        <td style="min-width: 200px; vertical-align: top;">
            <fieldset class="groupbox">
                <section>
                    <script type="text/javascript">
                        jQuery(document).ready(function () {
                            jQuery('@ID("#form")').validate({
                                rules: {
                                    value: {
                                        required: true
                                    }
                                }
                            });
                            jQuery('@ID("#txt_account")').autocomplete({
                                source: function (request, response) {
                                    jQuery.post('@Html.Raw(Url.Action(Loc.Act("Autocomplete").Ctrl("Account").Area("Membership")))', request, response);
                                },
                                minLength: 3,
                                select: function (event, ui) {
                                    jQuery('@ID("#hidden_account")').val(ui.item.id);
                                }
                            });
                        });
                    </script>
                    <form id="@ID("form")" action="@Url.Action(Loc.Act("Create").Ctrl("Rating").NoArea())" method="post">
                        <input type="hidden" name="operation" value="CreateCatalogSupplierRating" />
                        <input type="hidden" name="returnUrl" value="@Request.RawUrl" />
                        <input type="hidden" name="holderID" value="@JDM.Int32(Model.EntityID)" />
                        <table>
                            <tr>
                                <td>
                                    <label>@T(Res.Name("Account"))</label>
                                </td>
                                <td>
                                    <input id="@ID("hidden_account")" type="hidden" name="accountID" value="0" />
                                    <input id="@ID("txt_account")" type="text" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label>@T(Res.Name("Value"))</label>
                                </td>
                                <td>
                                    <input type="text" name="value" value="0" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label>@T(Res.Name("Comment"))</label>
                                </td>
                                <td>
                                    <input type="text" name="commentID" value="0" />
                                </td>
                            </tr>
                        </table>
                        <ul class="bar toolbar">
                            <li><button class="button" type="submit">@T(Res.In("Common").Of("Act").Name("Submit"))</button></li>
                        </ul>
                    </form>
                </section>
            </fieldset>
        </td>
        <td style="width: 100%; vertical-align: top;">
            <ul class="cloud">
            @foreach(var i in Model.Ratings)
            {
                <li>
                    <ul class="bar inlinebar">
                        <li><a class="confirm" href="@Url.Action(Loc.Act("Delete").Ctrl("Rating").NoArea().Set(new
                        {
                            operation = "DeleteCatalogSupplierRating",
                            returnUrl = Request.RawUrl,
                            id = JDM.Int32(i.EntityID)
                        }))">x</a></li>
                    </ul>
                    @String.Format(T(Res.Name("Entry")), 
                        JDM.Byte(i.Value), 
                        i.Account != null 
                            ? JDM.String(i.Account.Email) 
                            : T(Res.In("Common").Of("Vocab").Name("NA")), 
                        i.Comment != null 
                            ? JDM.String(i.Comment.EntityID)
                            : T(Res.In("Common").Of("Vocab").Name("NA")))
                </li>
            }
            </ul>
        </td>
    </tr>
</table>
